<template>
	<view>
		<view style="background-color: rgba(255, 255, 255, 0.3); top: 0; left: 0;"
			:style="{paddingTop: CustomBar + 40 + 'px'}"
			class="fixed vw-100 vh-100 ">
			<view v-if="azjgs" class="bg-white">
				<view class="cu-form-group margin-top solid-bottom">
					<view class="title">公司名称</view>
					<input class="" placeholder="请输入中介公司名称" v-model="azjgs.zjgsnc" />
				</view>
				<view class="cu-form-group margin-top solid-bottom">
					<view class="title">位置：</view>
					<view>
						<text @click="sp = true;">
							<text class="" v-if="azjgs.pcode">{{cmap[azjgs.pcode].criname}}</text>
							<text class="" v-if="azjgs.scode">{{cmap[azjgs.scode].criname}}</text>
							<text class="" v-if="azjgs.qcode">{{cmap[azjgs.qcode].criname}}</text>
							<text v-else>请选择</text>
							<text class="cuIcon-right"></text>
						</text>
					</view>
				</view>
				<view class="cu-form-group align-start margin-top solid">
					<view class="title">详细地址：</view>
					<textarea v-model="azjgs.dz" placeholder="请输入详细地址"></textarea>
				</view>
				<view class="padding ">
					<button @click="save" class="cu-btn block bg-yellow lg">保存</button>
				</view>
			</view>
			
		</view>
		<md-position v-if="sp" @change="adChange" @close="sp = false" :astore="md" />
	</view>
</template>

<script>
	import mdposition from "@/components/md-position.vue";
	
	export default {
		props: {
			value: {
				type: Object,
				default: function() {
					return {
						zjgsid: "",
						zjgsnc: "",
						dz: "",
						fzzjid: "",
						pcode: "",
						scode: "",
						qcode: "",
					}
				}
			}
		},
		components: {
			"md-position": mdposition
		},
		data: function() {
			return {
				CustomBar: this.CustomBar,
				sp: false,
				cmap: this.location.localmap.cmap,
				md: {
					jd: "", //经度
					wd: "", //纬度
				},
				azjgs: undefined,
			};
		},
		created: function() {
			this.azjgs = this.value;
		},
		methods: {
			adChange: function(md) {
				this.azjgs.pcode = md.pcode;
				this.azjgs.scode = md.scode;
				this.azjgs.qcode = md.qcode;
				this.azjgs.dz = md.address;
				this.azjgs.jd = md.jd;
				this.azjgs.wd = md.wd;
				this.sp = false;
			},
			save: function() {
				
				if (!this.azjgs.zjgsnc) {
					this.message.warning("请输入中介公司名称");
					return;
				}
				
				if (!this.azjgs.dz) {
					this.message.warning("请输入详细地址");
					return;
				}
				
				
				this.$emit("input", this.azjgs);
				this.$emit("close");
			}
		},
	}
</script>

<style>
</style>